﻿@page "/Bas/Supplier/Create"
@using nERP.ViewModel.Bas.SupplierVMs
@using System.ComponentModel.DataAnnotations
@inherits BasePage

<div>
    <ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit">
        <Row ItemsPerRow="ItemsPerRow.Three" RowType="RowType.Normal">
            <BootstrapInputGroupLabel @bind-Value="@Model.Entity.SupplierCode" required="true" />
            <BootstrapInputGroup>
                <BootstrapInput @bind-Value="@Model.Entity.SupplierCode"></BootstrapInput>
                <Button @ref="@btnSN" Icon="fas fa-plus" Text="@WtmBlazor.Localizer["Page.生成号码"]" OnClick="OnCreateSNAsync"></Button>
            </BootstrapInputGroup>
            <BootstrapInput @bind-Value="@Model.Entity.SupplierName" />
            <BootstrapInput @bind-Value="@Model.Entity.ContactPerson" />
            <BootstrapInput @bind-Value="@Model.Entity.PhoneNumber" />
            <BootstrapInput @bind-Value="@Model.Entity.Email" />
            <BootstrapInput @bind-Value="@Model.Entity.Faxing" />
            <BootstrapInput @bind-Value="@Model.Entity.BeginPay" />
            <BootstrapInput @bind-Value="@Model.Entity.EndPay" />
            <BootstrapInput @bind-Value="@Model.Entity.TaxtRate" />
            <BootstrapInput @bind-Value="@Model.Entity.Remark" />
            <BootstrapInput @bind-Value="@Model.Entity.Address" />
            <BootstrapInput @bind-Value="@Model.Entity.Bank" />
            <BootstrapInput @bind-Value="@Model.Entity.TaxpayerNumber" />
            <BootstrapInput @bind-Value="@Model.Entity.BankAccount" />
            <BootstrapInput @bind-Value="@Model.Entity.LandlinePhone" />
            <WTUploadFile @bind-Value="@Model.Entity.SupplierFile" />
        </Row>

        <div class="modal-footer table-modal-footer">
            <Button ButtonType="ButtonType.Submit" IsAsync="true" Text="@WtmBlazor.Localizer["Sys.Submit"]" />
            <Button OnClick="OnClose" Text="@WtmBlazor.Localizer["Sys.Close"]" />
        </div>

    </ValidateForm>

</div>



@code {
    [Parameter]
    public string id { get; set; }
    [Parameter]
    public string[] ids { get; set; }
    private SupplierVM Model = new SupplierVM();
    private ValidateForm vform { get; set; }
    private async Task Submit(EditContext context)
    {


        await PostsForm(vform, "/api/Bas/Supplier/Create", (s) => "Sys.OprationSuccess");
    }
    public void OnClose()
    {
        CloseDialog();
    }

    protected override async Task OnInitializedAsync()
    {



        await base.OnInitializedAsync();
    }
    private Button btnSN { get; set; }
    private async Task OnCreateSNAsync(MouseEventArgs e)
    {
        var SN = await GetNewSN2("供应商", false);
        Model.Entity.SupplierCode = SN;
        btnSN.SetDisable(true);
    }
}
